home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
8206
/
8206.xpi
/
content
/
service.xml
< prev
next >
Wrap
Extensible Markup Language
|
2010-02-02
|
11KB
|
291 lines
<?xml version="1.0"?>
<!DOCTYPE bindings PUBLIC "-//MOZILLA//DTD XBL V1.0//EN" "http://www.mozilla.org/xbl">
<bindings
xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="service-base">
<content>
<xul:hbox anonid="img-box" popup="_child" pack="center" align="center" style="padding-left: 2px">
<xul:image anonid="service-dropdown" src="chrome://wisestamp/skin/narrow.png"/>
<xul:hbox width="16" height="16" pack="center" align="center">
<xul:image anonid="img-current" width="16" height="16" style="margin-right: 5px"/>
</xul:hbox>
<xul:image anonid="img-box-arrow"/>
<xul:menupopup anonid="service-popup" position="after_start"
onpopupshowing="this.parentNode.parentNode.servicePopupShowing(event);"
onpopupshown="this.parentNode.parentNode.servicePopupShown(event);">
</xul:menupopup>
</xul:hbox>
<xul:textbox anonid="textbox" flex="1" xbl:inherits="value"/>
<xul:hbox anonid="question-block" tooltip="_child" align="center" pack="center" width="20">
<xul:image src="chrome://wisestamp/skin/question.png" anonid="question" width="15" height="15" />
<xul:tooltip anonid="help-popup" style="max-width: 600px;" onpopupshown="this.parentNode.parentNode.serviceHelpShown(event)">
<xul:image anonid="help-image"/>
</xul:tooltip>
</xul:hbox>
</content>
<implementation>
<constructor>
<![CDATA[
if (this.service){
this.init();
}
]]>
</constructor>
<field name="_service">null</field>
<property name="service" >
<getter>
<![CDATA[
if (!this._service)
this._service = this.getAttribute("service");
return this._service;
]]>
</getter>
<setter>
<![CDATA[
if (this._service){
this.parentNode.setAttribute("value",
this.parentNode.getAttribute("value").replace(this._service,val));
}
this.setAttribute("service", val);
this._service = val;
]]>
</setter>
</property>
<property name="prefs">
<getter>
if (!this._prefs){
this._prefs = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefService);
this._prefs = this._prefs.getBranch("extensions.wisestamp.");
}
return this._prefs;
</getter>
</property>
<field name="_strings">null</field>
<property name="strings">
<getter>
<![CDATA[
if (!this._strings){
this._strings = Components.classes["@mozilla.org/intl/stringbundle;1"].getService(Components.interfaces.nsIStringBundleService);
this._strings = this._strings.createBundle("chrome://wisestamp/locale/wisestamp.properties");
}
return this._strings;
]]>
</getter>
</property>
<field name="textbox">document.getAnonymousElementByAttribute(this, "anonid","textbox")</field>
<property name="value" onget="return this.textbox.value"
onset="this.textbox.value = val;"/>
<method name="initIcon">
<parameter name="aFolder"/>
<parameter name="aType"/>
<body>
<![CDATA[
//var serviceLabel = document.getAnonymousElementByAttribute
// (this,"anonid","service-label");
//serviceLabel.value = this.service;
var imageBox = document.getAnonymousElementByAttribute(this,"anonid","img-box");
imageBox.setAttribute("tooltiptext",this.strings.GetStringFromName(this.service));
var currentImage = document.getAnonymousElementByAttribute(this,"anonid","img-current");
currentImage.src = "chrome://wisestamp/skin/icons/"+this.service+".png";
this.textbox.emptyText = this.strings.GetStringFromName(aType+"-emptytext");
var services = this.prefs.getCharPref(aType).split(",");
var popup = document.getAnonymousElementByAttribute(this,"anonid","service-popup");
while(popup.lastChild)
popup.removeChild(popup.lastChild);
var xulns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
for (var i = 0;i<services.length;i++){
var id = services[i];
if (id != this.service){
var menuitem = document.createElementNS(xulns, "menuitem");
menuitem.setAttribute("label",this.strings.GetStringFromName(id));
menuitem.setAttribute("tooltiptext",this.strings.GetStringFromName(id));
menuitem.setAttribute("class","menuitem-iconic");
menuitem.setAttribute("style","list-style-image: url('chrome://wisestamp/skin/icons/"+id+".png'); margin-top: 1px;");
menuitem.setAttribute("oncommand", "this.parentNode.parentNode." + "parentNode.switchTo('"+id+"')");
popup.appendChild(menuitem);
}
}
popup.appendChild(document.createElement("menuseparator"));
var menuitem = document.createElementNS(xulns, "menuitem");
menuitem.setAttribute("label",this.strings.
GetStringFromName("removeService"));
menuitem.setAttribute("class","menuitem-iconic remove-service");
//menuitem.setAttribute("style","list-style-image: url('chrome://wisestamp/skin/icons/"+
// id+".png')");
menuitem.setAttribute("oncommand", "this.parentNode.parentNode." + "parentNode.remove()");
popup.appendChild(menuitem);
]]>
</body>
</method>
<method name="remove">
<body>
<![CDATA[
var val = this.parentNode.getAttribute("value").split(/\s*,\s*/);
var idx = val.indexOf(this.service);
val.splice(idx,1);
this.parentNode.setAttribute("value",val.join(","));
this.parentNode.removeChild(this);
]]>
</body>
</method>
<method name="servicePopupShown">
<parameter name="aEvent"/>
<body>
<![CDATA[
]]>
</body>
</method>
<method name="servicePopupShowing">
<parameter name="aEvent"/>
<body>
<![CDATA[
]]>
</body>
</method>
<!-- <method name="WISELOG">-->
<!-- <parameter name="msg"/>-->
<!-- <body>-->
<!-- <![CDATA[-->
<!-- Components.utils.reportError(msg);-->
<!-- var consoleService = Components.classes["@mozilla.org/consoleservice;1"]-->
<!-- .getService(Components.interfaces.nsIConsoleService);-->
<!-- consoleService.logStringMessage(msg);-->
<!-- ]]>-->
<!-- </body>-->
<!-- </method>-->
</implementation>
<handlers>
</handlers>
</binding>
<binding id="service" extends="chrome://wisestamp/content/service.xml#service-base">
<implementation>
<method name="switchTo">
<parameter name="aService"/>
<body>
<![CDATA[
<!-- dump("switch to: "+aService+"\n");-->
this.service = aService;
var popup = document.getAnonymousElementByAttribute(this,"anonid","service-popup");
popup.hidePopup();
var vals = WiseStampOptions.data.sigs[WiseStampOptions.type].services[aService];
var used = this.parentNode.getAttribute("value").split(",");
var idx = 0;
for (var i=0;i<used.length;i++){
if (used[i]==aService)
idx++;
}
var val = vals[idx];
if (!val || val=="undefined")
val = "";
this.value = val;
this.init();
this.textbox.focus();
]]>
</body>
</method>
<method name="init">
<body>
<![CDATA[
this.initIcon("socialservices","services");
]]>
</body>
</method>
<method name="servicePopupShowing">
<parameter name="aEvent"/>
<body>
<![CDATA[
]]>
</body>
</method>
<method name="servicePopupShown">
<parameter name="aEvent"/>
<body>
<![CDATA[
<!-- dump("service popup shown: "+aEvent+"\n")-->
//var diff = screen.height - aEvent.target.boxObject.y - aEvent.target.boxObject.height - 110;
<!-- //dump("diff: "+diff+"\n");-->
//aEvent.target.setAttribute("height",diff);
//aEvent.target.sizeTo(aEvent.target.boxObject.width,diff);
]]>
</body>
</method>
<method name="serviceHelpShown">
<parameter name="aEvent"/>
<body>
<![CDATA[
var src = "chrome://wisestamp/skin/url-example/"+this.service+".png";
var imageEle = document.getAnonymousElementByAttribute(this,"anonid","help-image");
imageEle.setAttribute("src",src);
]]>
</body>
</method>
</implementation>
</binding>
<binding id="im" extends="chrome://wisestamp/content/service.xml#service-base">
<implementation>
<constructor>
document.getAnonymousElementByAttribute(this,"anonid","question-block").hidden = true;
</constructor>
<method name="switchTo">
<parameter name="aService"/>
<body>
<![CDATA[
this.service = aService;
var popup = document.getAnonymousElementByAttribute(this,"anonid","service-popup");
popup.hidePopup();
var vals = WiseStampOptions.data.sigs[WiseStampOptions.type].im[aService];
var used = this.parentNode.getAttribute("value").split(",");
var idx = -1;
for (var i=0;i<used.length;i++){
if (used[i]==aService)
idx++;
}
<!-- dump("indx: "+idx+"\n")-->
var val = vals[idx];
if (!val || val=="undefined")
val = "";
this.value = val;
this.init();
this.textbox.focus();
]]>
</body>
</method>
<method name="init">
<body>
<![CDATA[
this.initIcon("im","im");
]]>
</body>
</method>
<method name="serviceHelpShown">
<parameter name="aEvent"/>
<body>
<![CDATA[
return false;
]]>
</body>
</method>
<method name="servicePopupShowing">
<parameter name="aEvent"/>
<body>
<![CDATA[
]]>
</body>
</method>
</implementation>
</binding>
</bindings>